package Io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyDemo2 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis=new FileInputStream("aaaa.jpg");
        FileOutputStream fos=new FileOutputStream("aaaa_cp2.jpg");

        byte[] data=new byte[1024*10];
        int len;
        byte[] data2=new byte[3];


        long start=System.currentTimeMillis();
        while ((len=fis.read(data2))!=-1){
            fos.write(data2,0,len);
        }
        long end=System.currentTimeMillis();
        System.out.println((end-start));
        fis.close();
        fos.close();

        /* byte[] data=new byte[1024*10];
        byte[] data2=new byte[3];


        long start=System.currentTimeMillis();
        while (fis.read(data2)!=-1){
            fos.write(data2);
        }
        long end=System.currentTimeMillis();
        System.out.println((end-start));
        fis.close();
        fos.close();

       */
    }
}
